#include <cassert>
#include "uvstring.h"

void testStreq();
void testGetBool();
void testIsNumeric();

int main() {
    testStreq();
    testGetBool();
    testIsNumeric();
    return 0;
}

void testStreq() {
    assert(uv::string::streq("hello", "hello", false));
    assert(uv::string::streq("hello", "hello", true));

    assert(uv::string::streq("HELLO", "hello", false));
    assert(!uv::string::streq("HELLO", "hello", true));
    assert(uv::string::streq("HeLlO", "hello", false));
    assert(!uv::string::streq("HeLlO", "hello", true));

    assert(uv::string::streq("hello", "HELLO", false));
    assert(!uv::string::streq("hello", "HELLO", true));
    assert(uv::string::streq("hello", "hElLo", false));
    assert(!uv::string::streq("hello", "hElLo", true));
}

void testGetBool() {
    bool val;
    assert(uv::string::getBool("1", val) && val);
    assert(uv::string::getBool("0", val) && !val);
    assert(uv::string::getBool("true", val) && val);
    assert(uv::string::getBool("false", val) && !val);

    assert(!uv::string::getBool("2", val));
    assert(!uv::string::getBool("flase", val));    
}

void testIsNumeric() {
    assert(uv::string::isNumeric("1"));
    assert(uv::string::isNumeric("+1"));
    assert(uv::string::isNumeric("-1"));
    assert(uv::string::isNumeric("999999999999999"));
    assert(uv::string::isNumeric("+999999999999999"));
    assert(uv::string::isNumeric("-999999999999999"));
    assert(uv::string::isNumeric("0x5"));
    assert(uv::string::isNumeric("+0x5"));
    assert(uv::string::isNumeric("-0x5"));
    assert(uv::string::isNumeric("0X10"));
    assert(uv::string::isNumeric("+0X10"));
    assert(uv::string::isNumeric("-0X10"));

    assert(!uv::string::isNumeric("hello"));
}
